export default url => {
    const crud = window.$crud(url)

    const getUsers = (ids) => window.$axios({
        url: `${url}s`,
        method: 'post',
        data:{ids}
    })

    const updateState = (id,state) => window.$axios({
        url: `${url}/state/${id}`,
        method: 'put',
        params:{
            state
        }
    })

    const resetPassword = (id) => window.$axios({
        url: `${url}/resetpsw/${id}`,
        method: 'put'
    })

    const validatorPassword = (psw) => window.$axios({
        url: `${url}/validator/${psw}`,
        method: 'get'
    })
    
    const updatePassword = (req) => window.$axios({
        url: `${url}/password`,
        method: 'put',
        data:req
    })

    const login = (account, password,params) => window.$axios({
        url: `login`,
        method: 'post',
        meta: {
            isToken: false
        },
        params:params,
        data: {
            account,
            password
        }
    })
    
    const getLoginInfo = () => window.$axios({
        url: 'login/pc',
        method: 'get'
    })

    const removeCache = () => window.$axios({
        url: 'login/cache',
        method: 'post'
    })
    const getRootRids = () => window.$axios({
        url: `other/role/getrootrids`,
        method: 'get'
    })
    const getNextRids = (roleId) => window.$axios({
        url: `other/role/getnextrids/${roleId}`,
        method: 'get'
    })

    crud.syncData = (startTime) => window.$axios({
        url: `other/organizes/syncusers`,
        method: 'post',
        params:{startTime:startTime},
    })

    const getusersbyroleid = (roleId) => window.$axios({
        url: `other/role/getusersbyroleid/${roleId}`,
        method: 'get'
    })
    const GetRule = () => window.$axios({
        url: `systemconfig/otherPasswordRule/GetRule`,
        method: "get",
    });
    const GetRuleByRole = () => window.$axios({
        url: `systemconfig/otherPasswordRule/byrole`,
        method: "get",
    });

    const checkIndate = () => window.$axios({
        url: `systemconfig/otherPasswordRule/checkPasswordIndate`,
        method: "get",
    });

    const checkIndateByRole = () => window.$axios({ 
        url: `systemconfig/otherPasswordRule/checkpsdindatebyrole`,
        method: "get",
    });


    return {
        ...crud,
        getUsers,
        updateState,
        resetPassword,
        validatorPassword,
        updatePassword,

        login,
        getLoginInfo,

        removeCache,
        getRootRids,
        getNextRids,
        getusersbyroleid,
        GetRule,
        GetRuleByRole,
        checkIndate,
        checkIndateByRole

    }
}